Handle empty button boxes gracefully
authorMatthias Clasen <mclasen@redhat.com>
Thu, 4 Nov 2010 03:00:05 +0000 (23:00 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 4 Nov 2010 03:01:09 +0000 (23:01 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=633915

gtk/gtkbbox.c

index ad31d3f77974d500a84ff561ac06bc16dd7c43c3..5fdf837a15b2391216eab010a35240d00c9c6f6e 100644 (file)
@@ -774,13 +774,19 @@ gtk_button_box_size_allocate (GtkWidget     *widget,
                 x = allocation->x;
                 secondary_x = x + primary_size + n_primaries * childspacing;
               }
-            else
+            else if (nvis_children == 1)
               {
-                /* one or zero children, just center */
+                /* one child, just center */
                 childspacing = width;
                 x = secondary_x = allocation->x
                                   + (allocation->width - widths[0]) / 2;
               }
+            else
+              {
+                /* zero children, meh */
+                childspacing = width;
+                x = secondary_x = allocation->x + allocation->width / 2;
+              }
           }
         else
           {
@@ -790,12 +796,18 @@ gtk_button_box_size_allocate (GtkWidget     *widget,
                 y = allocation->y;
                 secondary_y = y + primary_size + n_primaries * childspacing;
               }
-            else
+            else if (nvis_children == 1)
               {
-                /* one or zero children, just center */
+                /* one child, just center */
                 childspacing = height;
                 y = secondary_y = allocation->y
-                        + (allocation->height - heights[0]) / 2;
+                                     + (allocation->height - heights[0]) / 2;
+              }
+            else
+              {
+                /* zero children, meh */
+                childspacing = height;
+                y = secondary_y = allocation->y + allocation->height / 2;
               }
           }